package com.sunrise.xdoc.entity.config;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;

import com.sunrise.xdoc.entity.AbstractCodeEntity;

/**
 * Danh muc. FullCode (in AbstractCodeEntity) = type + specificCode
 * 
 */
@Entity
@Table(name = "config_internal_code")
@Inheritance(strategy = InheritanceType.JOINED)
public class InternalCode extends AbstractCodeEntity implements Serializable {
    private static final long serialVersionUID = 1L;
    private InternalCodeType type; // type must be defined by system.
    private String name;
    private Integer rank = 0; // so thu tu, dung de sap xep tren list

    @Column(name = "type", nullable = false)
    @Enumerated(EnumType.STRING)
    public InternalCodeType getType() {
        return type;
    }

    public void setType(InternalCodeType type) {
        this.type = type;
    }

    @Column(name = "name", unique = true)
    @Length(max = 250)
    @NotBlank
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "rank")
    public Integer getRank() {
        return rank;
    }

    public void setRank(Integer rank) {
        this.rank = rank;
    }

    public enum InternalCodeType {
        FOLK, RELIGION, CITY, WORKING_METHOD, EDU_STATUS, CERTIFICATION, CERT_METHOD, CERT_LEVEL, UNIVERSITY, CERT_SUBJECT, COMPUTER_LEVEL, POLITIC_LEVEL, ECO_MANAGE_LEVEL, NATION_MANAGE_LEVEL, HOC_HAM, HOC_VI, CAP_BAC_QDOI, CHUC_VU_QDOI, NHOM_MAU, SUC_KHOE, DOI_TUONG_CSACH, THANH_PHAN_GD, DANH_HIEU_DPHONG, CHUC_VU_CTY
    }
}
